package com.inspur.jzsxxzx.service.muluzhili.impl;

import com.inspur.jzsxxzx.entity.muluzhili.UpDataCatalog;
import com.inspur.jzsxxzx.mapper.muluzhili.UpDataCatalogMapper;
import com.inspur.jzsxxzx.service.muluzhili.UpDataCatalogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class UpDataCatalogServiceImpl implements UpDataCatalogService {
    
    @Autowired
    private UpDataCatalogMapper upDataCatalogMapper;
    
    @Override
    public List<UpDataCatalog> findAll() {
        return upDataCatalogMapper.findAll();
    }
    
    @Override
    public List<UpDataCatalog> findPageByCondition(String cataTitle, String importedByOrgName, int page, int limit) {
        int offset = (page - 1) * limit;
        return upDataCatalogMapper.findPageByCondition(cataTitle, importedByOrgName, offset, limit);
    }
    
    @Override
    public int countByCondition(String cataTitle, String importedByOrgName) {
        return upDataCatalogMapper.countByCondition(cataTitle, importedByOrgName);
    }
    
    @Override
    public UpDataCatalog findById(Integer id) {
        return upDataCatalogMapper.findById(id);
    }
    
    @Override
    public boolean save(UpDataCatalog upDataCatalog) {
        try {
            return upDataCatalogMapper.insert(upDataCatalog) > 0;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    
    @Override
    public boolean update(UpDataCatalog upDataCatalog) {
        try {
            return upDataCatalogMapper.update(upDataCatalog) > 0;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    
    @Override
    public boolean deleteById(Integer id) {
        try {
            return upDataCatalogMapper.deleteById(id) > 0;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    
    @Override
    public boolean batchSave(List<UpDataCatalog> upDataCatalogList) {
        try {
            return upDataCatalogMapper.batchInsert(upDataCatalogList) > 0;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public Integer findMaxId() {
        return upDataCatalogMapper.findMaxId();
    }
}